package com.xhapi.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.xhapi.config.XfXhConfig;
import com.xhapi.pojo.entity.ApiResult;
import com.xhapi.pojo.entity.Text;
import com.xhapi.pojo.vo.TextCorrectionVO;
import com.xhapi.service.TextService;
import com.xhapi.utils.ApiResultHandler;
import com.xhapi.utils.textCorrectionUtils.WebTextCorrection;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import static com.xhapi.utils.textCorrectionUtils.WebTextCorrection.doPostJson;
import static com.xhapi.utils.textCorrectionUtils.WebTextCorrection.gson;

@RestController
@CrossOrigin
@RequestMapping("/text_correction")
@RequiredArgsConstructor
@Slf4j
public class TextCorrectionController {
    @Autowired
    TextService textService;
    /*
    * 这个接口是上传一个文本内容，会自动进行纠错，返回纠错后的信息
    * */
    @PostMapping
    public ApiResult textCorrection(@RequestBody Text textCorrection) throws Exception {
        return ApiResultHandler.success(textService.correctText(textCorrection));
    }
}

